﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <unordered_map>
using namespace std;

class Solution {
public:
    vector<vector<int>> generateMatrix(int x) {
        vector<vector<int>> ret(x, vector<int>(x, 0));
        int n = x, m = x;
        int top = 0, bottom = n - 1, left = 0, right = m - 1;
        int tmp = 1;
        while (left <= right && top <= bottom)
        {
            for (int i = left; i <= right; i++)
            {
                ret[top][i] = tmp;
                tmp++;
            }
            top++;
            for (int i = top; i <= bottom; i++)
            {
                ret[i][right] = tmp;
                tmp++;
            }
            right--;
            if (top <= bottom)
            {
                for (int i = right; i >= left; i--)
                {
                    ret[bottom][i] = tmp;
                    tmp++;
                }
            }
            bottom--;
            if (left <= right)
            {
                for (int i = bottom; i >= top; i--)
                {
                    ret[i][left] = tmp;
                    tmp++;
                }
            }
            left++;
        }
        return ret;
    }
};
int main()
{
    vector<int> arr(10, 0);
    return 0;
}
